from flask import request, Blueprint

from api.decorators import cache
from api.slider import get_json_response, get_rank, get_rank_info

book_rank = Blueprint('book_rank', __name__)


# 获取排行榜
@book_rank.route('/rank')
@cache
def rank_response():
    content = get_rank()
    return get_json_response(content, request)


# 获取排行榜的书
@book_rank.route('/rank/book')
@cache
def rank_info_response():
    rank_id = request.args.get('rankId', '')
    content = get_rank_info(rank_id)
    return get_json_response(content, request)
